using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

using SharpCore.Data;

namespace TF.Access {
	public partial class TF_EventLine {
		#region Fields
		private int eventLineId;
		private int eventId;
		private int seq;
		private string startDate;
		private string startTime;
		private string endDate;
		private string endTime;
		private int cityIDFrom;
		private int cityIDTo;
		private decimal linePrice;
		private int tTID;
		private bool isReturn;
		private string remark;
		private int lanuageId;
		private int scheduleStatus;
		private int stepDay;
		private int cityId;
		#endregion
		
		#region Constructors
		/// <summary>
		/// Initializes a new instance of the TF_EventLine class.
		/// </summary>
		public TF_EventLine() {
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_EventLine class.
		/// </summary>
		public TF_EventLine(int eventId, int seq, string startDate, string startTime, string endDate, string endTime, int cityIDFrom, int cityIDTo, decimal linePrice, int tTID, bool isReturn, string remark, int lanuageId, int scheduleStatus, int stepDay, int cityId) {
			this.eventId = eventId;
			this.seq = seq;
			this.startDate = startDate;
			this.startTime = startTime;
			this.endDate = endDate;
			this.endTime = endTime;
			this.cityIDFrom = cityIDFrom;
			this.cityIDTo = cityIDTo;
			this.linePrice = linePrice;
			this.tTID = tTID;
			this.isReturn = isReturn;
			this.remark = remark;
			this.lanuageId = lanuageId;
			this.scheduleStatus = scheduleStatus;
			this.stepDay = stepDay;
			this.cityId = cityId;
		}
		
		/// <summary>
		/// Initializes a new instance of the TF_EventLine class.
		/// </summary>
		public TF_EventLine(int eventLineId, int eventId, int seq, string startDate, string startTime, string endDate, string endTime, int cityIDFrom, int cityIDTo, decimal linePrice, int tTID, bool isReturn, string remark, int lanuageId, int scheduleStatus, int stepDay, int cityId) {
			this.eventLineId = eventLineId;
			this.eventId = eventId;
			this.seq = seq;
			this.startDate = startDate;
			this.startTime = startTime;
			this.endDate = endDate;
			this.endTime = endTime;
			this.cityIDFrom = cityIDFrom;
			this.cityIDTo = cityIDTo;
			this.linePrice = linePrice;
			this.tTID = tTID;
			this.isReturn = isReturn;
			this.remark = remark;
			this.lanuageId = lanuageId;
			this.scheduleStatus = scheduleStatus;
			this.stepDay = stepDay;
			this.cityId = cityId;
		}
		#endregion
		
		#region Properties
		/// <summary>
		/// Gets or sets the EventLineId value.
		/// </summary>
		public int EventLineId {
			get { return eventLineId; }
			set { eventLineId = value; }
		}
		
		/// <summary>
		/// Gets or sets the EventId value.
		/// </summary>
		public int EventId {
			get { return eventId; }
			set { eventId = value; }
		}
		
		/// <summary>
		/// Gets or sets the Seq value.
		/// </summary>
		public int Seq {
			get { return seq; }
			set { seq = value; }
		}
		
		/// <summary>
		/// Gets or sets the StartDate value.
		/// </summary>
		public string StartDate {
			get { return startDate; }
			set { startDate = value; }
		}
		
		/// <summary>
		/// Gets or sets the StartTime value.
		/// </summary>
		public string StartTime {
			get { return startTime; }
			set { startTime = value; }
		}
		
		/// <summary>
		/// Gets or sets the EndDate value.
		/// </summary>
		public string EndDate {
			get { return endDate; }
			set { endDate = value; }
		}
		
		/// <summary>
		/// Gets or sets the EndTime value.
		/// </summary>
		public string EndTime {
			get { return endTime; }
			set { endTime = value; }
		}
		
		/// <summary>
		/// Gets or sets the CityIDFrom value.
		/// </summary>
		public int CityIDFrom {
			get { return cityIDFrom; }
			set { cityIDFrom = value; }
		}
		
		/// <summary>
		/// Gets or sets the CityIDTo value.
		/// </summary>
		public int CityIDTo {
			get { return cityIDTo; }
			set { cityIDTo = value; }
		}
		
		/// <summary>
		/// Gets or sets the LinePrice value.
		/// </summary>
		public decimal LinePrice {
			get { return linePrice; }
			set { linePrice = value; }
		}
		
		/// <summary>
		/// Gets or sets the TTID value.
		/// </summary>
		public int TTID {
			get { return tTID; }
			set { tTID = value; }
		}
		
		/// <summary>
		/// Gets or sets the IsReturn value.
		/// </summary>
		public bool IsReturn {
			get { return isReturn; }
			set { isReturn = value; }
		}
		
		/// <summary>
		/// Gets or sets the Remark value.
		/// </summary>
		public string Remark {
			get { return remark; }
			set { remark = value; }
		}
		
		/// <summary>
		/// Gets or sets the LanuageId value.
		/// </summary>
		public int LanuageId {
			get { return lanuageId; }
			set { lanuageId = value; }
		}
		
		/// <summary>
		/// Gets or sets the ScheduleStatus value.
		/// </summary>
		public int ScheduleStatus {
			get { return scheduleStatus; }
			set { scheduleStatus = value; }
		}
		
		/// <summary>
		/// Gets or sets the StepDay value.
		/// </summary>
		public int StepDay {
			get { return stepDay; }
			set { stepDay = value; }
		}
		
		/// <summary>
		/// Gets or sets the CityId value.
		/// </summary>
		public int CityId {
			get { return cityId; }
			set { cityId = value; }
		}
		#endregion
		
		#region Methods
		/// <summary>
		/// Saves a record to the TF_EventLine table.
		/// </summary>
		public void Insert() {
			eventLineId = Convert.ToInt32(SqlClientUtility.ExecuteScalar("TF_EventLineInsert", eventId, seq, startDate, startTime, endDate, endTime, cityIDFrom, cityIDTo, linePrice, tTID, isReturn, remark, lanuageId, scheduleStatus, stepDay, cityId));
		}
		
		/// <summary>
		/// Updates a record in the TF_EventLine table.
		/// </summary>
		public void Update() {
			SqlClientUtility.ExecuteNonQuery("TF_EventLineUpdate", eventLineId, eventId, seq, startDate, startTime, endDate, endTime, cityIDFrom, cityIDTo, linePrice, tTID, isReturn, remark, lanuageId, scheduleStatus, stepDay, cityId);
		}
		
		/// <summary>
		/// Deletes a record from the TF_EventLine table by its primary key.
		/// </summary>
		public void Delete() {
			SqlClientUtility.ExecuteNonQuery("TF_EventLineDelete", eventLineId);
		}
		
		/// <summary>
		/// Selects a single record from the TF_EventLine table.
		/// </summary>
		public static TF_EventLine Select(int eventLineId) {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_EventLineSelect", eventLineId)) {
				if (dataReader.Read()) {
					return MakeTF_EventLine(dataReader);
				} else {
					return null;
				}
			}
		}
		
		/// <summary>
		/// Selects all records from the TF_EventLine table.
		/// </summary>
		public static List<TF_EventLine> SelectAll() {
			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_EventLineSelectAll")) {
				List<TF_EventLine> tF_EventLineList = new List<TF_EventLine>();
				while (dataReader.Read()) {
					TF_EventLine tF_EventLine = MakeTF_EventLine(dataReader);
					tF_EventLineList.Add(tF_EventLine);
				}
				return tF_EventLineList;
			}
		}
		
		/// <summary>
		/// Creates a new instance of the TF_EventLine class and populates it with data from the specified SqlDataReader.
		/// </summary>
		private static TF_EventLine MakeTF_EventLine(SqlDataReader dataReader) {
			TF_EventLine tF_EventLine = new TF_EventLine();
			
			if (dataReader.IsDBNull(0) == false) {
				tF_EventLine.EventLineId = dataReader.GetInt32(0);
			}
			if (dataReader.IsDBNull(1) == false) {
				tF_EventLine.EventId = dataReader.GetInt32(1);
			}
			if (dataReader.IsDBNull(2) == false) {
				tF_EventLine.Seq = dataReader.GetInt32(2);
			}
			if (dataReader.IsDBNull(3) == false) {
				tF_EventLine.StartDate = dataReader.GetString(3);
			}
			if (dataReader.IsDBNull(4) == false) {
				tF_EventLine.StartTime = dataReader.GetString(4);
			}
			if (dataReader.IsDBNull(5) == false) {
				tF_EventLine.EndDate = dataReader.GetString(5);
			}
			if (dataReader.IsDBNull(6) == false) {
				tF_EventLine.EndTime = dataReader.GetString(6);
			}
			if (dataReader.IsDBNull(7) == false) {
				tF_EventLine.CityIDFrom = dataReader.GetInt32(7);
			}
			if (dataReader.IsDBNull(8) == false) {
				tF_EventLine.CityIDTo = dataReader.GetInt32(8);
			}
			if (dataReader.IsDBNull(9) == false) {
				tF_EventLine.LinePrice = dataReader.GetDecimal(9);
			}
			if (dataReader.IsDBNull(10) == false) {
				tF_EventLine.TTID = dataReader.GetInt32(10);
			}
			if (dataReader.IsDBNull(11) == false) {
				tF_EventLine.IsReturn = dataReader.GetBoolean(11);
			}
			if (dataReader.IsDBNull(12) == false) {
				tF_EventLine.Remark = dataReader.GetString(12);
			}
			if (dataReader.IsDBNull(13) == false) {
				tF_EventLine.LanuageId = dataReader.GetInt32(13);
			}
			if (dataReader.IsDBNull(14) == false) {
				tF_EventLine.ScheduleStatus = dataReader.GetInt32(14);
			}
			if (dataReader.IsDBNull(15) == false) {
				tF_EventLine.StepDay = dataReader.GetInt32(15);
			}
			if (dataReader.IsDBNull(16) == false) {
				tF_EventLine.CityId = dataReader.GetInt32(16);
			}

			return tF_EventLine;
		}
		#endregion
	}
}
